package com.eqs.enterprisequestionnaire.controller;

import com.eqs.enterprisequestionnaire.result.R;
import com.eqs.enterprisequestionnaire.service.WordCloudService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/textAnalysis")
public class TextAnalysisController {
    @Autowired
    WordCloudService wordCloudService;

    //问题词频
    @GetMapping("/wordFrequencies/{questionId}")
    public R<Map<String, Integer>> generateWordFrequencies(@PathVariable Integer questionId){
        return R.success(wordCloudService.generateWordFrequencies(questionId));
    }

    //问题平均文本量
    @GetMapping("/averageText/{questionId}")
    public R<Double> averageOfQuestion(@PathVariable Integer questionId){
        Double result=wordCloudService.getAverageWordOfQuestion(questionId);
        return R.success(result);
    }

    @GetMapping("/wordFrequencies/gender/{questionId}")
    public R generateWordFrequenciesByGender(@PathVariable Integer questionId){
        return R.success(wordCloudService.generateGenderSpecificWordCloud(questionId));
    }
}
